package com.wxb.fourpillars.util;

import com.nlf.calendar.Lunar;

import java.util.Date;

/**
 * 袁天罡称骨算命工具类
 */
public class YuanTianGangUtil {

    /**
     * 重量
     */
    public Integer kg = 0;

    /**
     * 根据年干支取重
     * @param ganZhi 年干支
     * @return
     */
    private static  Integer getKgByYear(String ganZhi){
        switch (ganZhi) {
            case "甲子":  return    12;
            case "丙子":  return   16;
            case "戊子":  return   15;
            case "庚子":  return   7;
            case "壬子":  return   5;
            case "乙丑":  return   9;
            case "丁丑":  return   8;
            case "己丑":  return   7;
            case "辛丑":  return    7;
            case "癸丑":  return   7;
            case "丙寅":  return   6;
            case "戊寅":  return   8;
            case "庚寅":  return   9;
            case "壬寅":  return   9;
            case "甲寅":  return   12;
            case "丁卯":  return   7;
            case "己卯":  return    19;
            case "辛卯":  return   12;
            case "癸卯":  return   12;
            case "乙卯":  return   8;
            case "戊辰":  return   12;
            case "庚辰":  return   12;
            case "壬辰":  return   10;
            case "甲辰":  return   8;
            case "丙辰":  return    8;
            case "己巳":  return   5;
            case "辛巳":  return   6;
            case "癸巳":  return   7;
            case "乙巳":  return   7;
            case "丁巳":  return   6;
            case "庚午":  return   9;
            case "壬午":  return   8;
            case "甲午":  return   15;
            case "丙午":  return   13;
            case "戊午":  return   19;
            case "辛未":  return   8;
            case "癸未":  return   7;
            case "乙未":  return   6;
            case "丁未":  return   5;
            case "己未":  return   6;
            case "壬申":  return   7;
            case "甲申":  return   5;
            case "丙申":  return   5;
            case "戊申":  return   14;
            case "庚申":  return   8;
            case "癸酉":  return   8;
            case "乙酉":  return   15;
            case "丁酉":  return   14;
            case "己酉":  return   5;
            case "辛酉":  return   16;
            case "甲戌":  return   15;
            case "丙戌":  return   6;
            case "戊戌":  return   14;
            case "庚戌":  return   9;
            case "壬戌":  return   10;
            case "乙亥":  return   9;
            case "丁亥":  return   16;
            case "己亥":  return   9;
            case "辛亥":  return   17;
            default:  return   6;
        }
    }

    /**
     * 根据农历月份获取重量
     * @param month 农历月份
     * @return
     */
    private static Integer getKgByMonth(Integer month){
        switch (month) {
            case 1:  return    6;
            case 2:  return   7;
            case 3:  return   18;
            case 4:  return   9;
            case 5:  return   5;
            case 6:  return   16;
            case 7:  return   9;
            case 8:  return   15;
            case 9:  return   18;
            case 10:  return   8;
            case 11:  return   9;
            default:  return   5;
        }
    }

    /**
     * 获取日期重量
     * @param day
     * @return
     */
    private static Integer getKgByDay(Integer day){
        switch (day) {
            case 1:  return    5;
            case 2:  return   1;
            case 3:  return   8;
            case 4:  return   15;
            case 5:  return   16;
            case 6:  return   15;
            case 7:  return   8;
            case 8:  return   16;
            case 9:  return   8;
            case 10:  return   16;
            case 11:  return   9;
            case 12:  return    17;
            case 13:  return   8;
            case 14:  return   17;
            case 15:  return   10;
            case 16:  return   8;
            case 17:  return   9;
            case 18:  return   18;
            case 19:  return   5;
            case 20:  return   10;
            case 21:  return   10;
            case 22:  return   9;
            case 23:  return   8;
            case 24:  return   9;
            case 25:  return   15;
            case 26:  return   18;
            case 27:  return   7;
            case 28:  return   8;
            case 29:  return   16;
            default:  return   6;
        }
    }

    /**
     * 获取时辰重量
     * @param time 时支
     * @return
     */
    private static Integer getKgByTime(String time){
        switch (time) {
            case "子":  return    16;
            case "丑":  return   6;
            case "寅":  return   7;
            case "卯":  return   10;
            case "辰":  return   9;
            case "巳":  return   16;
            case "午":  return   10;
            case "未":  return   8;
            case "申":  return   8;
            case "酉":  return   9;
            case "戌":  return   6;
            default:  return   6;
        }
    }

    /**
     * 根据性别和重量获取袁天罡称骨口诀
     * @param kg        重量
     * @param gender    性别 1男2女
     * @return
     */
    public static String getStringByKg(Integer kg,Integer gender){
        if(gender==1){
            switch (kg) {
                case 21:  return    "短命非业谓大空，平生灾难事重重，凶祸频临陷逆境，终世困苦事不成";
                case 22:  return    "身寒骨冷苦伶仃，此命推来行乞人，劳劳碌碌无度日，终年打拱过平生";
                case 23:  return    "此命推来骨肉轻，求谋做事事难成，妻儿兄弟实难靠，外出他乡做散（善）人";
                case 24:  return    "此命推来福禄无，门庭困苦总难荣，六亲骨肉皆无靠，流浪他乡作老翁";
                case 25:  return    "此命推来祖业微，门庭营度似稀奇，六亲骨肉如冰炭，一世勤劳自把持";
                case 26:  return    "平生衣禄苦中求，独自营谋事不休，离祖出门宜早计，晚来衣禄自无休";
                case 27:  return    "一生作事少商量，难靠祖宗作主张，独马单枪空做去，早年晚岁总无长";
                case 28:  return    "一生行事似飘蓬，祖宗产业在梦中，若不过房改名姓，也当移徒二三通";
                case 29:  return    "初年运限未曾亨，纵有功名在后成，须过四旬才可立，移居改姓始为良";
                case 30:  return    "劳劳碌碌苦中求，东奔西走何日休，若使终身勤与俭，老来稍可免忧愁";
                case 31:  return    "忙忙碌碌苦中求，何日云开见日头，难得祖基家可立，中年衣食渐无忧";
                case 32:  return    "初年运蹇事难谋，渐有财源如水流，到得中年衣食旺，那时名利一齐收";
                case 33:  return    "早年作事事难成，百计徒劳枉费心，半世自如流水去，后来运到得黄金";
                case 34:  return    "此命福气果如何，僧道门中衣禄多，离祖出家方为妙，朝晚拜佛念弥陀";
                case 35:  return    "生平福量不周全，祖业根基觉少传，营事生涯宜守旧，时来衣食胜从前";
                case 36:  return    "不须劳碌过平生，独自成家福不轻，早有福星常照命，任君行去百般成";
                case 37:  return    "此命般般事不成、弟兄少力自孤行。虽然祖业须微有，来得明时去不明";
                case 38:  return    "一身骨肉最清高，早入簧门姓氏标。待到年将三十六，蓝衫脱去换红袍";
                case 39:  return    "此命终身运不通，劳劳作事尽皆空，苦心竭力成家计，到得那时在梦中";
                case 40:  return    "平生衣禄是绵长，件件心中自主张。前面风霜多受过，后来必定享安康";
                case 41:  return    "此命推来事不同，为人能干异凡庸，中年还有逍遥福，不比前时运未通";
                case 42:  return    "得宽怀处且宽怀，何用双眉皱不开，若使中年命运济，那时名利一齐来";
                case 43:  return    "为人心性最聪明，作事轩昂近贵人，衣禄一生天数定，不须劳碌过平生";
                case 44:  return    "万事由天莫苦求，须知福禄命里收，少壮名利难如意，晚景欣然更不忧";
                case 45:  return    "名利推来竟若何，前番辛苦后奔波。命中难养男与女，骨肉扶持也不多";
                case 46:  return    "东西南北尽皆通，出姓移居更觉隆，衣禄无亏天数定，中年晚景一般同";
                case 47:  return    "此命推为旺末年，妻荣子贵自怡然，平生原有滔滔福，财源滚滚似水流";
                case 48:  return    "初年运道未曾亨，若是蹉跎再不兴，兄弟六亲皆无靠，一身事业晚年成";
                case 49:  return    "此命推来福不轻，自成自立显门庭，从来富贵人钦敬，使婢差奴过一生";
                case 50:  return    "为利为名终日劳，中年福禄也多遭，老来是有财星照，不比前番目下高";
                case 51:  return    "一世荣华事事通，不须劳碌自亨通，弟兄叔侄皆如意，家业成时福禄宏";
                case 52:  return    "一世荣华事事能，不须劳思自然宁，宗族欣然心皆好，家业丰亨自称心";
                case 53:  return    "此格推为气量真，兴家发达在其中，一生福禄安排定，却是人间一富翁";
                case 54:  return    "此命推来厚且清，诗书满腹看功成，丰衣足食自然稳，正是人间有福人";
                case 55:  return    "走马扬鞭争利名，少年作事费筹论，一朝福禄源源至，富贵荣华显六亲";
                case 56:  return    "此格推来礼义通，一身福禄用无穷，甜酸苦辣皆尝过，滚滚财源稳且丰";
                case 57:  return    "福禄丰盈万事全，一身荣耀乐天年。名扬威震人争羡，此世逍遥宛似仙";
                case 58:  return    "平生福禄自然来，名利兼全福寿偕，雁塔题名为贵客，紫袍金带走金阶";
                case 59:  return    "细推此格妙且清，必定才高礼义通，甲第之中应有分，扬鞭走马显威荣";
                case 60:  return    "一朝金榜快题名，显祖荣宗立大功，衣禄定然原裕足，田园财帛更丰盈";
                case 61:  return    "不作朝中金榜客，定为世上大财翁，聪明天赋经书熟，名显高科自是荣";
                case 62:  return    "此命生来福不穷，读书必定显亲宗，紫衣金带为卿相，富贵荣华皆可同";
                case 63:  return    "命主为官福禄长，得来富贵实丰常，名题金塔传金榜，定中高科天下扬";
                case 64:  return    "此格威权不可当，紫袍金带尘高堂。荣华富贵谁能及？万古留名姓氏扬";
                case 65:  return    "细推此命福非轻，富贵荣华孰与争？定国安邦人极品，威声显赫震寰瀛";
                case 66:  return    "此格人间一福人，堆金积玉满堂春，从来富贵由天定，正笏垂绅谒圣君";
                case 67:  return    "此命生来福自宏，田园家业最高隆，平生衣禄盈丰足，一世荣华万事通";
                case 68:  return    "富贵由天莫苦求，万金家计不须谋，如今不比前翻事，祖业根基千古留";
                case 69:  return    "君是人间衣禄星，一生富贵众人钦，纵然福禄由天定，安享荣华过一生";
                case 70:  return    "此命推来福禄宏，不须愁虑苦劳心，一生天定衣与禄，富贵荣华主一生";
                case 71:  return    "此命生成大不同，公侯卿相在其中。一生自有逍遥福，富贵荣华极品隆";
                default:  return   "此格世界罕有生，十代积善产此人。天上紫微来照命，统治万民乐太平";
            }
        }else {
            switch (kg) {
                case 21:
                    return "生身此命运不通，乌云盖月黑朦胧。莫向故园载花木，可来幽地种青松";
                case 22:
                    return "女命孤冷独凄身，此身推来路乞人。操心烦恼难度日，一生痛苦度光阴";
                case 23:
                    return "女命生来轻薄人，营谋事作难称心。六亲骨肉亦无靠，奔走劳碌困苦门";
                case 24:
                    return "女命推来福禄无，治家艰难辛苦多。丈夫儿女不亲爱，奔走他乡作游姑";
                case 25:
                    return "此命一身八字低，家庭艰辛多苦妻。娘家亲友冷如炭，一生勤劳多忧眉";
                case 26:
                    return "平生依禄但苦求，两次配夫带忧愁。咸酸苦辣他偿过，晚年衣食本无忧";
                case 27:
                    return "此格做事单独强，难告夫君作主张。心问口来口问心，晚景衣禄宜自生";
                case 28:
                    return "女命生来八字轻，为善作事也无因。你把别人当亲生，别人对你假殷情";
                case 29:
                    return "花支艳来硬性身，自奔自力不求人。若问求财方可止，在苦有甜度光阴";
                case 30:
                    return "女命推来比郎强，婚姻大事碍无障。中年走过坎坷地，末年渐经行前强";
                case 31:
                    return "早年行运在忙头，劳碌奔波苦勤求。力劳心把家立 ，后来晚景免忧愁";
                case 32:
                    return "时逢运来带吉神，从有凶星转灰尘。真变假来假成真，结拜弟妹当亲生";
                case 33:
                    return "初限命中有变化，中年可比树落花。勤俭持家难度日，晚年成业享荣华";
                case 34:
                    return "矮巴勾枣难捞枝，看破红尘最相宜。谋望求财空费力，婚姻三娶两次离";
                case 35:
                    return "女子走冰怕冰薄，出行交易受残霜。婚姻周郎休此意，官司口舌须相加";
                case 36:
                    return "忧悉常锁两眉间，家业挂心不等闲。从今以后防口角，任意行移不相关";
                case 37:
                    return "此命推来费运多，若作摧群受折磨。山路崎岖吊下耳，左插右安心难留";
                case 38:
                    return "凤鸣岐山四方扬，女命逢此大吉昌。走失夫君音信有，晚年衣禄财盈箱";
                case 39:
                    return "女命推来运未能，劳碌奔波一场空。好似俊鸟在笼锁，中年未限凄秋风";
                case 40:
                    return "当前月令运不良，千辛万苦受煎熬。女身受得多苦难，晚年福禄比密甜";
                case 41:
                    return "此命推来一般艰，女子为人很非凡。中年逍遥多自在，晚年更比中年超";
                case 42:
                    return "杜井破废已多年，今有泉水出来鲜。生济竭人称美 ，运来转喜安然";
                case 43:
                    return "推车靠涯道路通，女名求财也无穷。婚姻出配无阻碍，疾病口舌离身躬";
                case 44:
                    return "夜梦金银醒来空，立志谋业运不通。婚姻难成交易散，夫君趟失未见踪";
                case 45:
                    return "女命终身驳杂多，六亲骨肉不相助。命中男女都难养，劳碌辛苦还奔波";
                case 46:
                    return "孤舟行水离沙滩，离乡出外早过家。非口舌皆无碍 ，姻合配紫微房";
                case 47:
                    return "时来运转喜开颜，多年枯木逢春花。枝叶重生多茂盛，凡人见得都赞夸";
                case 48:
                    return "一朵鲜花镜中开，看着极好取不来。劝你休把镜花想，此命推来主可癫";
                case 49:
                    return "一生为人福宏名，心兹随君显门庭。容貌美丽惹人爱，银钱富足万事成";
                case 50:
                    return "马氏太公不相和，好命逢此忧凝多。恩人无义反为仇，是非平地起风波";
                case 51:
                    return "肥羊一群入出场，防虎逢之把口张。适口充饥心欢喜，女命八字大吉昌";
                case 52:
                    return "顺风行舟扯起帆，上天又助一顺风。不用费力逍遥去，任意顺行大亨通";
                case 53:
                    return "此命相貌眉目清，文武双全功名成。一生衣禄皆无缺，可算世上积福人";
                case 54:
                    return "运开满腹好文章，谋事求财大吉祥。出行交易多得稳，到处亨通姓名扬";
                case 55:
                    return "发政旅仁志量高，女命求财任他乡。交舍婚姻多有意，无君出外有音耗";
                case 56:
                    return "明珠辉吐离埃来，女有口有清散开。走失郎君当两归，交易有成永无灾";
                case 57:
                    return "游鱼戏水被网惊，踊身变化入龙门。三根杨柳垂金钱，万朵桃花显价能";
                case 58:
                    return "此命推来转悠悠，时运未来莫强求。幸得今日重反点，自有好运在后头";
                case 59:
                    return "雨雪载途活泥泞，交易不安难出生。疾病还拉婚姻慢，谋望求财事难寻";
                case 60:
                    return "女命八字喜气和，谋事求财吉庆多。口舌渐消疾病少，夫君走别归老窠";
                case 61:
                    return "缘木求鱼事多难，虽不得鱼无害反。若是行险弄巧地，事不遂心枉安凡";
                case 62:
                    return "指日高升气象新，走失待人有信音。好命遇事遂心好，伺病口舌皆除根";
                case 63:
                    return "五官脱运难抬头，妇命须当把财求。交易少行有人助，一生衣禄不须愁";
                case 64:
                    return "俊鸟曾得出胧中，脱离为难显威风。一朝得意福力至，东南西北任意通";
                case 65:
                    return "女命推来福非轻，兹善为事受人敬。天降文王开基业，八百年来富贵门";
                case 66:
                    return "时来运转闺阁楼，贤德淑女君子求。击鼓乐之大吉庆，女命逢此喜悠悠";
                case 67:
                    return "乱丝无头定有头，碰得亲事暂折磨。交易出行无好处，谋事求财心不遂";
                case 68:
                    return "水底明月不可捞，女命早限运未高。交易出行难获利，未运终得渐见好";
                case 69:
                    return "太公封祖不非凡，女子求财稳如山。交易合伙多吉庆，疾病口角遗天涯";
                case 70:
                    return "本命推断喜气新，恰遇郎君金遂心。坤身来交正当运，富贵衣禄乐平生";
                default:
                    return "此命推来宏运交，不须再愁苦劳难。一生身有衣禄福，安享荣华胜班超";
            }
        }
    }

    /**
     * 获取袁天罡称骨口诀
     * @param date      日期
     * @param gender    性别1男2女
     * @return
     */
    public static String getYuanTianGang(Date date,Integer gender){
        Lunar lunar = new Lunar(date);
        Integer kg = 0;
        kg+=getKgByYear(lunar.getYearGan()+lunar.getYearZhi());
        kg+=getKgByMonth(lunar.getMonth());
        kg+=getKgByDay(lunar.getDay());
        kg+=getKgByTime(lunar.getTimeZhi());

        return getStringByKg(kg,gender);
    }


}
